// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import verify from './vue-verify-plugin/src'
import vueResource from 'vue-resource'
import VueI18n from 'vue-i18n'
import './assets/common.css'
import './assets/px-rem.js'
import JsEncrypt from 'jsencrypt/bin/jsencrypt'
import tool from './tools/tool'
// 将jsencrypt压入到Vue
Vue.prototype.$jsEncrypt = JsEncrypt

let myRules = {
  checkPassword: {
    test: function (val) {
      if (!val.match(/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,12}$/)) {
        return false
      }
      return true
    },
    message: '字母和数字组合'
  },
  // 自定义手机号验证、增加香港
  myMobile: {
    test: (val) => {
      if (!val.match(/(^1[23456789]{1}\d{9}$)|(^852\d{8}$)/)) {
        return false
      }
      return true
    },
    message: '手机号格式不正确'
  }

}
Vue.use(verify, { blur: true, rules: myRules })
Vue.use(vueResource)
Vue.use(VueI18n)
Vue.config.productionTip = false

Vue.filter('dateTime', (value) => {
  return tool.dateFormatTime(value, 'yyyy-MM-dd HH:mm:ss')
})

// 当前js的new Date
Vue.filter('dateTimeDate', (value) => {
  return tool.dateFormat(value, 'yyyy-MM-dd HH:mm:ss')
})

Vue.filter('imgDomain', (value) => {
  let url = 'http://imgnew.e-gatenet.cn/'
  return url + value
})
const symbol = tool.getQueryString('currencySymbol')
const i18n = new VueI18n({
  // 定义默认语言
  locale: symbol && symbol.toLowerCase().indexOf('hk') >= 0 ? 'zh-hk' : 'zh-cn',
  messages: {
    'zh-cn': require('./language/zh-cn'),
    'zh-hk': require('./language/zh-hk')
  }
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  i18n,
  template: '<App/>',
  components: { App }
})
